FILE1 = r'C:\Documents and Settings\madlee\Desktop\PDB\DNA-1.msd'
FILE2 = r'C:\Documents and Settings\madlee\Desktop\PDB\DNA.msd'

import kuai
PPF1 = open(r'F:\Madlee\Job\TEAM\xdh\DNA.eqt')

pr2amber = {}

for i in PPF1:
    tokens = i.split()
    pr2amber[tokens[0]] = tokens[2] 
        
from sets import Set
mol1 = kuai.read_mol(FILE1)
mol2 = kuai.read_mol(FILE2)

assert len(mol1.atoms) == len(mol2.atoms)
map = {}
for i in range(len(mol1.atoms)):
    a1 = mol1.atoms[i]
    a2 = mol2.atoms[i]
    type2 = a2.type + "/" + a2.residure 
    type1 = a1.type
    if type1 not in map:
        map[type1] = Set(), Set(),
    if type2 in pr2amber:
        map[type1][0].add(pr2amber[type2])
    else:
        map[type1][1].add(type2)
    
for k, v in map.iteritems():
    print k, ": ", ", ".join(v[0]), ":", ", ".join(v[1]) 
